const express = require('express')
const app = express()
const mysql = require('mysql')
const conn = mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'root',
    database:'001node_mysql'
})

//查
const sqlStr = 'select * from 00users where isdel = 0'
conn.query(sqlStr,(err,res) => {
    if(err) return console.log('失败');
    console.log(res);
})

//新增
// const user = {uname:'张三',age:19,gender:'男'}
// const sqlStr2 = "insert into 00users set ?"
// conn.query(sqlStr2,user,(err,res) => {
//     if(err) return console.log('失败');
    
// })

//修改
// const user = {id:2,uname:'小蓝',age:33,gender:'nv'}
// const sqlStr3 = 'update 00users set ? where id=?'
// conn.query(sqlStr3,[user,user.id],(err,res) => {
//     if(err) return console.log('失败');
//     console.log(res)
// })

//删除
// const sqlStr4 = 'delete from 00users where id = ?'
// conn.query(sqlStr4,2,(err,res) => {
//     if(err) return console.log('失败');
//     console.log(res)
// })